import React from 'react';
import Child from './Child.jsx'
class Parent extends React.Component {
  constructor(props) {
    super(props);
  }

  /** 实例化开始  */
  // UNSAFE_componentWillMount() {
  //   console.log('Parent: UNSAFE_componentWillMount')
  // }

  render() {
    return (
      <div>
        <h2>{ this.props.name }</h2>
        <Child name="Child"/>
      </div>
    )
  }

  componentDidMount() {
    console.log('Parent: componentDidMount')
  }

 /** 实例化结束 */

  /** 更新时 开始 */
  // UNSAFE_componentWillReceiveProps() {
  //   console.log('Parent: UNSAFE_componentWillReceiveProps')
  // }

  shouldComponentUpdate() {
    console.log('Parent: shouldComponentUpdate')
  }

  // UNSAFE_componentWillUpdate() {
  //   console.log('Parent: UNSAFE_componentWillUpdate')
  // }

  // 此处会再调用楼上的 render代码进行渲染

  componentDidUpdate() {
    console.log('Parent: componentDidUpdate')
  }
  /** 更新时 结束 */

  /** 组件销毁前 */
  componentWillUnmount() {
    console.log('Parent: componentWillUnmount')
  }
 
}

export default Parent;